


ssc install egenmore

use "${pathdata_baseline}/BaselineExperiment.dta", clear


************* Table 1: Regressions with several datasets

/* NOTES: the code is a little bit tricky as we use 2 datasets and need to adjust some stuff for each regression. 

working_data_2.dta: Column (I), (II) and (III) - this is just the standard data we always use + some additional dummies

recallandbelief.dta: Column (IV) and (V) - we use the data set that includes both recall data and Belief Impact.

Keep: we keep subjects who receive CONSISTENT stories in (I) - (IV) and subjects in the Story condition in (V)

Additionally, we perform a median split to see whether updating is affected 


*/


*indicator = 1 if in story treatment
gen story = 0 
replace story = 1 if inlist(condition_, "storyshort_neg", "storyshort_pos")

*median split depending on time in WAVE 1.

egen medianpagetime = median(pagetime)

egen medianpagetime_by_story = median(pagetime), by(story)

gen slow = .
replace slow = 1 if pagetime > medianpagetime_by_story
replace slow = 0 if pagetime <= medianpagetime_by_story



egen deciles_pagetime=xtile( pagetime ), nq(10)

/*
preserve
*Heterogeneity between positive and negative stories
	keep if story_type == "consistent"
	
	gen did = effect_recall - effect
	
	reg did positive_valence if inlist(condition_,"storyshort_neg", "storyshort_pos"), cluster(prolific_pid)
	
	reg did positive_valence if inlist(condition_,"statistic_neg", "statistic_pos"), cluster(prolific_pid)



restore
*/


preserve
	
	gen slowXstory = 0
	replace slowXstory = 1 if slow == 1 & story == 1
	
	*only keep consistent stories
	keep if story_type == "consistent"
	
	eststo clear
	*Column (I): immediate effect (Y) story dummy (X)
	eststo reg1: areg effect story, absorb(prolific_pid) cluster(prolific_pid)
	estadd scalar x = _b[_cons]


	*Column (II): delayed effect (Y) story dummy (X)
	eststo reg2: areg effect_recall story, absorb(prolific_pid) cluster(prolific_pid)
	estadd scalar x = _b[_cons]
	
	
	*Column (DI): immediate effect (Y) story dummy (X) + slow dummy and interaction
	eststo regD1: reg effect story slow slowXstory, cluster(prolific_pid)
	estadd scalar x = _b[_cons]


	*Column (DII): delayed effect (Y) story dummy (X) + slow dummy and interaction
	eststo regD2: reg effect_recall story slow slowXstory, cluster(prolific_pid) 
	estadd scalar x = _b[_cons]

	
	
	gen id= _n
	
	*Make the data long to have both immediate and delayed Belief Impact in one column
	reshape long effec, i(id) j(delay) string
	
	*only keep consistent stories

	*indicator = 1 if delayed Belief Impact
	gen delaydum = 0
	replace delaydum = 1 if delay =="t_recall"
	label variable delaydum "Delay"
	
	gen storyXdelay = 0
	replace storyXdelay = 1 if story == 1 & delaydum == 1
	
	gen delayXslow = 0
	replace delayXslow = 1 if slow == 1 & delaydum == 1
	
	gen storyXdelayXslow = 0
	replace storyXdelayXslow = 1 if story == 1 & delaydum == 1 & slow == 1


	rename effec effect_total

	*Column (III): Belief Impact delay and immediate pooled (Y) delay and story indicators (X)
	eststo reg3: areg effect_total story delaydum storyXdelay, absorb(prolific_pid) cluster(prolific_pid)
	estadd scalar x = _b[_cons]
	
	
	
	*Column (DIII): Belief Impact delay and immediate pooled (Y) delay and story indicators (X) + slow indicator and interactions
	eststo regD3: reg effect_total story delaydum storyXdelay slow delayXslow storyXdelayXslow slowXstory, cluster(prolific_pid)
	estadd scalar x = _b[_cons]
	


restore



	use "${pathdata_baseline}/BaselineExperiment.dta", clear
	
	*indicator = 1 if in story treatment
	gen story = 0 
	replace story = 1 if inlist(condition_, "storyshort_neg", "storyshort_pos")
	
	*median split depending on time in WAVE 1.

	egen medianpagetime = median(pagetime)

	gen slow = .
	replace slow = 1 if pagetime > medianpagetime
	replace slow = 0 if pagetime <= medianpagetime
	
	gen slowXstory = 0
	replace slowXstory = 1 if slow == 1 & story == 1
		
	
preserve
	use "${pathdata_baseline}/BaselineExperimentRecall.dta", clear
	
	egen medianpagetime = median(pagetime)


	gen slow = .
	replace slow = 1 if pagetime > medianpagetime
	replace slow = 0 if pagetime <= medianpagetime
	
	gen slowXstory = 0
	replace slowXstory = 1 if slow == 1 & story == 1
	
	*only keep consistent stories
	keep if story_type == "consistent"

	
	*Column (IV): Correct recall of information of type + valence (Y) indicator for story treatment (X)
	eststo reg4: areg recallcombined story, absorb(prolific_pid) cluster(prolific_pid)
	estadd scalar x = _b[_cons]
	
	
	*Column (DIV): Correct recall of information of type + valence (Y) indicator for story treatment (X) + slow indicator and interactions
	eststo regD4: reg recallcombined story slow slowXstory, cluster(prolific_pid)
	estadd scalar x = _b[_cons]

	
	
restore


preserve

	use "${pathdata_baseline}/BaselineExperimentRecall.dta", clear
	
	*only keep subjects in story treatment
	keep if story == 1
	
	gen mixed = 0
	replace mixed = 1 if story_type == "mixed"
	
	gen neutral = 0
	replace neutral = 1 if story_type == "neutral"

	
	*Column (V): Correct recall of information of type + valence (Y) indicator for valence of story content (X)
	eststo reg5: reg recallcombined mixed neutral, r
	estadd scalar x = _b[_cons]	
	
	
restore
	
		
		
		
		esttab regD1 regD2 regD3 regD4 using "${pathout_baseline}/tables/tableA8.tex", ///
		booktabs nonotes replace label nomtitles ///
		keep(story delaydum storyXdelay slow delayXslow storyXdelayXslow slowXstory) order(story delaydum storyXdelay slow slowXstory delayXslow storyXdelayXslow ) coeflabels( story "Story" delaydum "Delay" storyXdelay "Story $/times$ Delay" slow "Slow" delayXslow "Delay $/times$ Slow" storyXdelayXslow "Story $/times$ Delay $/times$ Slow" slowXstory "Story $/times$ Slow"  _cons "Control Mean") ///
		se(2) b(a2) stats(x N r2, fmt(2 0 2) label("Control Mean" "Observations" "R^2")) star(* 0.10 ** 0.05 *** 0.01) ///
		prehead("{\begin{tabular}{l*{4}{c}}\toprule\toprule&\multicolumn{4}{c}{\textit{Dependent variable:}}//[.1cm] &\multicolumn{3}{c}{Belief Impact} &  \multicolumn{1}{c}{Combined Recall} // \cmidrule(lr){2-4} \cmidrule(lr){5-5} // \textit{Sample:} &\multicolumn{1}{c}{Immediate} &\multicolumn{1}{c}{Delay} &\multicolumn{1}{c}{Pooled} &\multicolumn{1}{c}{Consistent} //")
		
		
		
 eststo clear
